import axios from "axios";


//  Utils写法
function formatDate(date, format = "-") {
  let year = date.toString().substring(0, 4);
  let month = date.toString().substring(4, 6);
  let day = date.toString().substring(6, 8);
  let result = year + format + month + format + day;
  return result;
}

function sum(num1, num2) {
  let result = num1 + num2;
  console.log(result);
  return result;
}

const token = {
  get: function(clientId, clientSecret) {
    let result = axios.post(
      `https://openapi.52cxy.cn/auth/token?clientId=${clientId}&clientSecret=${clientSecret}`
    );
    if (result.status == 200) {
      return result.data;
    } else {
      return result;
    }
  },
};

export {formatDate, sum, token};


//  对应的导入与使用
// import {sum, token} from "@shishuo/sdk";
// sum(1, 2)
// token.get('1', '2', '3', '4', '5').then((res) => {
//   console.log(res)
// })
